package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2018/12/19 17:34
 * @description
 */
public class Code258 {
    public int addDigits(int num) {
        if ((num + "").length() == 1) {
            return num;
        } else {
            int total = 0;
            for (char c : (num + "").toCharArray()) {
                total += c - 48;
            }
            return addDigits(total);
        }
    }
}
